// pages/mine/examination/single/post/detail/index.js
var app=getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    post: '',
    subjectList: [],
    subjectIndex: 0,
    questionIndex: 0,
    showButton: false,
    showImage:true,
    flag: true,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      post: options
    })
    wx.setNavigationBarTitle({
      title: options.title,
    })
    var _this = this;
    app.paiRequest("/app/mockexam/special/judge/subjectRecordList", {
      parentCode: options.id,
      theoryId: options.theoryId
    }).then(function (ress) {
      var subjectList = ress.data;
      _this.setData({
        subjectList: subjectList
      })
    })    
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  upList: function () {
    var subjectIndex = this.data.subjectIndex;
    var subjectList = this.data.subjectList;
    var subjectSize = subjectList.length;
    if (subjectIndex > 0) {
      this.setData({
        subjectIndex: subjectIndex - 1
      })
    } else if (subjectIndex == 0) {      
        this.setData({
          subjectIndex: 0
        })     
    }
  },
  nextList: function () {
    var subjectIndex = this.data.subjectIndex;
    var subjectList = this.data.subjectList;
    var subjectSize = subjectList.length;  
      
        subjectIndex = subjectIndex + 1;
        if (subjectIndex >= subjectSize) {
          this.setData({
            showButton: true
          })
        } else {
          this.setData({
            subjectIndex: subjectIndex
          })
        }
         
  },
  submitQuestion: function () {
    wx.navigateBack({
      delta: 1
    })
  },
})